#include <linux/init.h>
#include <linux/module.h>
#include <linux/of.h>
/*
mynode@0x12345678{
 string = "DC22041 everyone!!";
 uint   = <0x11223344 0xaabbccdd>;
 macaddr=[00 0c 29 7b f9 be];
 mixed = "hello",<0x112233>,[aa cc 00 12];
};
*/
struct device_node* node;
struct property* p;
static int __init mynode_init(void)
{
    int  i;
    const char* out_string;
    u32 d32[2];
    u8 d8[6];
    //通过路径获取节点
    node = of_find_node_by_path("/mynode@0x12345678");
    if (node == NULL) {
        printk("get node error\n");
        return -ENODATA;
    }

    of_property_read_string(node, "string", &out_string);
    printk("string = %s\n", out_string);

    of_property_read_u32_array(node, "uint", d32, 2);
    for (i = 0; i < 2; i++) {
        printk("uint[%d] = %#x\n", i, d32[i]);
    }

    of_property_read_u8_array(node, "macaddr", d8, 6);
    for (i = 0; i < 6; i++) {
        printk("macaddr[%d] = %#x\n", i, d8[i]);
    }

    return 0;
}
static void __exit mynode_exit(void)
{
}
module_init(mynode_init);
module_exit(mynode_exit);
MODULE_LICENSE("GPL");